package org.bright.controller;

import org.bright.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RequestMapping("user")
@RestController
public class UserController {
    @GetMapping("getUser")
    public String getTest(@RequestParam("name1") String name,@RequestParam("age1") int age){
        System.out.println(name+age);
        return name+age;
    }
    @GetMapping("postPrams")
    public String postPrams(User user){
        System.out.println(user);
        return String.valueOf(user);
    }
    @GetMapping("arraysParams")
    public String arraysParams(String[] hobbies){
        System.out.println("接收数组请求参数"+ Arrays.toString(hobbies));
        return Arrays.toString(hobbies);
    }

    @GetMapping("listParams")
    public String listParams(@RequestParam List<String> hobbies){
        System.out.println("接收数组请求参数"+ hobbies.toString());
        return hobbies.toString();
    }

    @GetMapping("jsonParams")
    public String jsonParams(@RequestBody User user){
        System.out.println("json数据传递"+ user);
        return user.toString();
    }

    @PostMapping("postParams")
    public String postParams(@RequestBody List<User> user){
        user.forEach(System.out::println);
        return user.toString();
    }
}
